package com.tongji.showroom.service
{ 
	import com.tongji.showroom.events.SearchSceneEvent;
	
	import flash.system.Security;
	
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.soap.WebService;
	
	import org.robotlegs.mvcs.Actor;
	
	/**
	 * 
	 * @author jiarong
	 * 
	 */
	public class SearchSceneService extends Actor
	{
		public var ws:WebService;
		
		public var tempStr:String = "";
		
		public function SearchSceneService()
		{
			super();
			ws = new WebService();
			ws.wsdl = "http://share.rryjw.com/VRService.asmx?wsdl";
			ws.useProxy = false;
			ws.loadWSDL();
			Security.loadPolicyFile("http://img.rryjw.com/crossdomain.xml");
		}
		
		/**
		 *根据场景Id和风格Id获取图片数据  
		 * @param scjId
		 * @param sfgId
		 * @param currentPage
		 * @param pageSize
		 * 
		 */		
		
		public function searchScene(userId:Number, scjId:String, sfgId:String, currentPage:int, pageSize:int):void
		{
			ws.SearchPublishSystemScene(userId, scjId, sfgId, currentPage, pageSize);
			ws.SearchPublishSystemScene.addEventListener(ResultEvent.RESULT, searchSceneResult);
			ws.SearchPublishSystemScene.addEventListener(FaultEvent.FAULT, faultHandler);
		}
		
		private function searchSceneResult(event:ResultEvent):void
		{
			dispatch(new SearchSceneEvent(SearchSceneEvent.UPDATE_SCENES, 0, null, null, 0, 0, event.result as String));
		}
		
		private function faultHandler(event:FaultEvent):void
		{
			Alert.show("失败" + event.fault.toString());
		}
	}
}